package com.jsyso.weixin.api;

import org.apache.commons.lang3.StringUtils;

import com.jsyso.jsyso.lang.JStringUtils;
import com.jsyso.jsyso.util.JsMap;
import com.jsyso.weixin.utils.Params;

/**
 * 用户管理相关API
 * @author janjan, xujian_jason@163.com
 *
 */
public class UserAPI extends API {
	protected static final String USER_INFO = "/cgi-bin/user/info";
	
	public API getUserInfo(String appid, String openId) {
		// 获取access_token
		JsMap resMap = AccessTokenAPI.getAccessToken(appid);
		String accessToken = resMap.get("access_token", String.class);
		if(StringUtils.isNotBlank(accessToken)) {
			this.getParams = Params.create("access_token", accessToken)
					.put("openid", openId).put("lang", "zh_CN");
			this.url = JStringUtils.newBuilder(API_WEIXIN_QQ_COM, USER_INFO).toString();
		}
		return this;
	}
	
}
